Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign in with QR (MSC3906) compatibility with Rust Crypto #3761

Merged
merged 13 commits into from
Jan 30, 2024

Conversation

hughns
Copy link
Member

@hughns hughns commented Sep 29, 2023

Currently the implementation of Sign in with QR (MSC3906) uses the deprecated crypto functions and relies on some capabilities not yet provided by the Rust crypto implementation. Required for element-hq/element-web#26350

CC @BillCarsonFr @richvdh

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

This change is marked as an internal change (Task), so will not be included in the changelog.

@hughns hughns changed the title Make MSC3906 implementation compatible with Rust Crypto Sign in with QR (MSC3906) compatibility with Rust Crypto Oct 9, 2023
@hughns hughns added the T-Task Tasks for the team like planning label Oct 9, 2023
@hughns
Copy link
Member Author

hughns commented Oct 9, 2023

@BillCarsonFr @richvdh If helpful I can progress this PR to get the simple changes that work when moving from client.crypto to client.getCypto(). Please let me know if you would like me to do so?

@richvdh
Copy link
Member

richvdh commented Oct 10, 2023

I'm not sure I have full context on this (maybe @BillCarsonFr knows more?) and I'm not quite clear what you're proposing, but any contributions that increase compatibility with Rust Crypto sound helpful!

@richvdh
Copy link
Member

richvdh commented Oct 10, 2023

Opened an issue to track this work: element-hq/element-web#26350

@BillCarsonFr
Copy link
Member

@BillCarsonFr @richvdh If helpful I can progress this PR to get the simple changes that work when moving from client.crypto to client.getCypto(). Please let me know if you would like me to do so?

Thanks @hughns, this work is tracked on our side and identified as required for initial release of web-r, but not a blocker to release on develop.io.

We will get to it after releasing to webR. As per your changes doesn't look like any API is missing? contrary to mobile side?

@hughns
Copy link
Member Author

hughns commented Oct 31, 2023

As per your changes doesn't look like any API is missing? contrary to mobile side?

@BillCarsonFr I've done some more work on the PR. I have found an API missing (or I can't find it, at least) on the Web R side which is the ability to programatically cross-sign another device.

The place in the code that this is done is here (#3761)

Is it possible to get this exposed or for the behaviour of setDeviceVerified to be backwards compatible?

@richvdh
Copy link
Member

richvdh commented Nov 28, 2023

The place in the code that this is done is here (#3761)

Unfortunately this link is 404ing :(

@richvdh
Copy link
Member

richvdh commented Nov 28, 2023

The place in the code that this is done is here (#3761)

Unfortunately this link is 404ing :(

I guess it means here

@richvdh
Copy link
Member

richvdh commented Nov 28, 2023

Is it possible to get this exposed or for the behaviour of setDeviceVerified to be backwards compatible?

I think it's probably best we distinguish clearly between the cross-signing case and the "mark as locally verified" case, not least because we can mark other users' devices as locally verified, but we cannot cross-sign them.

I can add a new method to CryptoApi.

@richvdh
Copy link
Member

richvdh commented Nov 29, 2023

Is it possible to get this exposed or for the behaviour of setDeviceVerified to be backwards compatible?

I think it's probably best we distinguish clearly between the cross-signing case and the "mark as locally verified" case, not least because we can mark other users' devices as locally verified, but we cannot cross-sign them.

I can add a new method to CryptoApi.

This is done in #3930

@hughns hughns requested a review from a team as a code owner January 12, 2024 09:06
@hughns hughns requested review from richvdh and t3chguy January 12, 2024 09:06
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks broadly good, but a few suggestions for cleanups and clarifications.

master_key: masterPublicKey,
});

return info;
}

/**
* Verify the device and cross-sign it.
* @param timeout - time in milliseconds to wait for device to come online
* @returns the new device info if the device was verified
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this documentation looks to be outdated. Please could you correct it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(changing the return type is technically a breaking change. @t3chguy are you happy for this to land without a major version bump?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking silence as acceptance here. Nothing should be using this method outside the js-sdk anyway.

src/rendezvous/MSC3906Rendezvous.ts Outdated Show resolved Hide resolved
src/rendezvous/MSC3906Rendezvous.ts Outdated Show resolved Hide resolved
src/rendezvous/MSC3906Rendezvous.ts Outdated Show resolved Hide resolved
src/rendezvous/MSC3906Rendezvous.ts Outdated Show resolved Hide resolved
Comment on lines +36 to +38
type UserID = string;
type DeviceID = string;
type Fingerprint = string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely convinced this is useful. As I understand it, this doesn't actually do much at the typescript level (ie, it won't complain if you end up using a DeviceID where it wanted a UserID), so the only purpose of such type aliasing is documentation... and frankly, I'd prefer to see documentation done as comments rather than as types.

I'm not going to insist on changing anything here: rather sharing a thought for future reference.

spec/unit/rendezvous/rendezvous.spec.ts Outdated Show resolved Hide resolved
spec/unit/rendezvous/rendezvous.spec.ts Outdated Show resolved Hide resolved
spec/unit/rendezvous/rendezvous.spec.ts Outdated Show resolved Hide resolved
Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this branch and I have been able to succesfully log in an Android (EAR) device using QR code. New device correctly verified and all secrets known locally (private cross signing keys and backup decryption key), history decryptable.

@BillCarsonFr BillCarsonFr self-assigned this Jan 19, 2024
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, there's a mix of comments here. Some of it is fairly unimportant stuff that I failed to notice on the previous review, so maybe not worth fixing now.

But it feels like you changed the return type of mockDevice and then failed to follow that change through, by simplifying the functions that call it. I'd like to see that finished.

src/rendezvous/MSC3906Rendezvous.ts Outdated Show resolved Hide resolved
src/rendezvous/MSC3906Rendezvous.ts Outdated Show resolved Hide resolved
src/rendezvous/MSC3906Rendezvous.ts Outdated Show resolved Hide resolved
spec/unit/rendezvous/rendezvous.spec.ts Outdated Show resolved Hide resolved
spec/unit/rendezvous/rendezvous.spec.ts Outdated Show resolved Hide resolved
spec/unit/rendezvous/rendezvous.spec.ts Outdated Show resolved Hide resolved
@BillCarsonFr BillCarsonFr requested a review from richvdh January 30, 2024 10:13
@andybalaam andybalaam dismissed richvdh’s stale review January 30, 2024 12:25

Changes addressed

@BillCarsonFr BillCarsonFr added this pull request to the merge queue Jan 30, 2024
Merged via the queue into develop with commit a8b3369 Jan 30, 2024
23 checks passed
@BillCarsonFr BillCarsonFr deleted the hughns/msc3906-rust-crypto branch January 30, 2024 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Task Tasks for the team like planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants